{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=893
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
   i,n:longint;
   mx,mn,k:int64;
 
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
read(n,k);
mx:=-maxlongint;
mn:=maxlongint;
for i:=1 to n do begin
    read(k);
    if k<mn then mn:=k;
    if k>mx then mx:=k;
end;
write(mx-mn);
end.